package servletDemo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


/*
 * request 相关
 * */


@WebServlet(name = "ServletA", value = "/ServletA")
public class ServletA extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("servletDemo.ServletA exec");
        String username = request.getParameter("username");
        String args = username + " is a java engineer !";
        request.setAttribute("career", args);
        /*转发*/

        request.getRequestDispatcher("/servletDemo.ServletB").forward(request,response);

        request.getRequestDispatcher("/ServletB").forward(request, response);

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
